$(function() {
    var form = layui.form
    var layer = layui.layer
    var id = localStorage.getItem('id')
    // console.log(id);
    $.ajax({
        type: 'get',
        url: '/admin/users/' +id,
        success:function(res) {
            // console.log(res);
            if(res.status !== 0 ) {
                return layer.msg(res.message)
            }
            form.val('editForm', res.data)
            
        } 
    })
    console.log('ok');
    $('#form_edit').submit(function(e) {
        e.preventDefault()
        var data = $(this).serialize()
        console.log(data);
        $.ajax({
            type: 'PUT',
            url: '/admin/upuser',
            data:  data,
            success: function(res) {
                // console.log(res);
                if(res.status !== 0) {
                    return layer.msg(res.message)
                }
                layer.msg(res.message, function() {
                    location.href = './user.html'
                })
            }
        })
    })
})